package bidgetserver;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Product {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private String author;

    @Persistent
    private String ProductKey;
    
    @Persistent
    private String Price;
    
    @Persistent
    private String IsBuy;
    
    @Persistent
    private Date date;
    
    @Persistent
    private boolean flag;
    
    @Persistent
    private String TimeAlert;

    @Persistent
    private String ProductPicture;  
    //link to the product's picture supplied by the client from eBay.
    
    @Persistent
    private String ProductName;
   
    @Persistent
    private String CellNum;
    
    
    //flag==true: this is a regular product; flag==0: this is a history product
    public Product(String author, String content, String IsBuy, Date date, boolean flag, String ProductPicture, String ProductName, String CellNum) {
        this.author = author;
        this.ProductKey = content;
        this.IsBuy = IsBuy;
        this.date = date;
        this.flag = flag;
        this.ProductName=ProductName;
        this.ProductPicture=ProductPicture;
        this.CellNum=CellNum;
        //initial price will be 100 million
        this.Price = "100000000";
        if(IsBuy.equals("1"))
        	this.TimeAlert = "0";
        else
        	this.TimeAlert = "1";
    }

    public Long getId() {
        return id;
    }

    public String getAuthor() {
        return author;
    }

    public String getKey() {
        return ProductKey;
    }
    
    public String getTimeAlert(){
    	return TimeAlert;
    }
    
    public boolean getflag() {
        return this.flag;
    }
    
    public String BuyOrSell() {
        return this.IsBuy;
    }
    
    public String getPrice() {
        return Price;
    }
    
    public String getProductPicture() {
        return ProductPicture;
    }
    
    public String getProductName() {
        return ProductName;
    }
    
    public String getCellNum() {
        return CellNum;
    }
    
    public void setPrice(String price) {
        this.Price = price;
    }
    
    public void setAlert() {
        this.TimeAlert = "1";
    }
    
    public Date getDate() {
        return date;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void setKey(String content) {
        this.ProductKey = content;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    
    public void setProductPicture(String ProductPicture) {
        this.ProductPicture = ProductPicture;
    }
    
    public void setProductName(String ProductName) {
        this.ProductName = ProductName;
    }
    
    public void setCellNum(String CellNum) {
        this.CellNum = CellNum;
    }
    
}
